<?php

namespace app\admin\validate\yxerp;

use think\Validate;

/**
 * @copyright 2025 银杏ERP
 * @author 银杏ERP
 * @version 1.0
 * @license http://www.hhyx.xyz
 * @developer Lhf
 */
class Sku extends Validate
{
    protected $rule = [
        'product_id' => 'require',
        'sku_code' => 'require|unique:yxerp_sku',
        'price' => 'require|float|egt:0',
        'stock' => 'require|integer|egt:0',
    ];
    
    protected $message = [
        'product_id.require' => '产品ID不能为空',
        'sku_code.require' => 'SKU编码不能为空',
        'sku_code.unique' => 'SKU编码已存在',
        'price.require' => '价格不能为空',
        'price.float' => '价格必须为数字',
        'price.egt' => '价格必须大于或等于0',
        'stock.require' => '库存不能为空',
        'stock.integer' => '库存必须为整数',
        'stock.egt' => '库存必须大于或等于0',
    ];
    
    protected $scene = [
        'add' => ['product_id', 'sku_code', 'price', 'stock'],
        'edit' => ['product_id', 'price', 'stock'],
    ];
}